<?php
namespace Admin\Controller;
use Think\Controller;
class PrizeController extends Controller {
    public function index(){
        $this->display();
    }
    //列表
    public function prizelist(){
        $prizemodel=M('prize');
        $prizes=$prizemodel->order('pid')->select();
        $this->prize=$prizes;
        $this->display();
	}
	//删除
	public function delprize($pid){
	$prizemodel=M('prize');	
	if (false!==$prizemodel->where("pid=$pid")->delete()) {
            $this->success('删除成功！');
        } else {
            $this->error('删除失败');
        }
		
	}
	//添加
    public   function prizeadd(){
        $prizes = D('prize'); 
        $data['pname']=I('post.pname');
        $data['ppic']=I('post.ppic');
        $data['pintroduce']=I('post.pintroduce');
        $data['pvalue']=I('post.pvalue');
        $data['myvalue']=I('post.myvalue');
        dump($data);
        
         if(false!==$prizes->add($data)){
             $this->success('成功','prizelist');
         }else{
            $this->error('失败','prizelist');
         }
        }

		//修改
        public   function editprize(){

        $prizes = M('prize'); 
        $pid=I('post.pid');
        $data['pname']=I('post.pname');
        $data['pintroduce']=I('post.pintroduce');
        $data['pvalue']=I('post.pvalue');
        $data['myvalue']=I('post.myvalue');  
        dump($data);
        if(false !== $prizes->where("pid=$pid")->save($data)){
            $this->success('成功','prizelist');
         }else{
            $this->error('失败');
         }

// $activitys = D('activity'); 
//               $aid=I('post.aid');
//         $data['aname']=I('post.aname');
//         $data['adate']=I('post.adate');
//         $data['aplace']=I('post.aplace');
//         $data['charge']=I('post.charge');
//         $data['atel']=I('post.atel');  
//         $data['acontent']=I('post.acontent');
//         dump($data);
//         if(false !== $activitys->where("aid=$aid")->save($data)){
//             $this->success('成功','activitylist');
//          }else{
//             $this->error('失败');
//          }


        }
        
        public function edit(){    
            $prizes = D('prize'); 
            $pid=$_GET['pid'];
            $res= $prizes->where("pid=$pid")->find();
            $this->prize=$res;
        
        $this->display();
        }
}